package foodmaterial.action;

import foodmaterial.config.ChoiceDataSource;
import foodmaterial.entity.DocumentTrack;
import foodmaterial.entity.JsonResult;
import foodmaterial.entity.ResultCode;
import foodmaterial.service.DocumentTrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/documentTrack")
@CrossOrigin(allowCredentials = "true")
public class DocumentTrackAction extends BaseAction{
    @Autowired
    private DocumentTrackService service ;

    @GetMapping("/queryDocumentTrack")
    @ChoiceDataSource
    public JsonResult<List<DocumentTrack>> queryDocumentTrack(Long documentId) {
        List<DocumentTrack> result = service.queryDocumentTrack(documentId) ;
        return new JsonResult(true, ResultCode.SUCCESS,result) ;
    }

    @GetMapping("/queryDocumentTrackCount")
    @ChoiceDataSource
    public JsonResult<Integer> queryDocumentTrackCount(Long documentId) {
        Integer result = service.queryDocumentTrackCount(documentId) ;
        return new JsonResult(true, ResultCode.SUCCESS,result) ;
    }

}
